Ext.define("Dict.controller.Article", {
	extend : "Ext.app.Controller",

	views : ["article.List", //
	"article.Edit", //
	"article.EditWindow" //
	],

	init : function() {
		console.log('Articles controller init');
		this.control({
			"viewport > panel" : {
				render : this.onPanelRendered
			},
			"articlelist" : {
				selectionchange : this.articlelistSelectionChange,
				itemdblclick : this.editArticle
			},
			"[action=createArticle]" : {

			},
			"[action=editActicle]" : {

			},
			"[action=saveActicle]" : {
				click : function(button) {
					alert("asd");
					var form = button.up("form").getForm();
					var val = form.findField("content").value;
					Ext.Msg.alert("[action=findArticle]", "<xmp>" + button + "</xmp>" + val);
				}
			},
			"[action=findArticle]" : {
				click : function(button) {
					var form = button.up("form").getForm();
					var val = form.findField("findtext").value;
					Ext.Msg.alert("[action=findArticle]", "<xmp>" + button + "</xmp>" + val);
				}
			},
			"tool" : {
				click : function(window) {
					console.log("Clicky clicky");
					console.log(window["name"]);
					console.log("Clicky clicky complete");
				}
			}
		});
		console.log('Articles controller .init complete');
	},
	onPanelRendered : function() {
		console.log('Articles.onPanelRendered');
	},
	onLaunch : function() {
		console.log("Articles controller onLaunch");
		console.log("Articles controller onLaunch complete");
	},
	articlelistSelectionChange : function(grid, selections, options) {
		console.log("Article controller articlelistSelectionChange");
	},
	editArticle : function(grid, record) {
		console.log("Edit article");
		var w = Ext.create("Dict.view.article.EditWindow", {
			name : "childWindow"
		});
		w.show();
		w.down("form").getForm().loadRecord(record);
		console.log("Edit article complete");
	},
	createArticle : function() {
		console.log("Create article");
	},
	findArticle : function() {
		console.log("Find article");
	}
});
